//
//  MKUIElementViewDetail.m
//  MKUI
//
//  Created by 苏尚进 on 2023/7/11.
//  Copyright © 2023 moon. All rights reserved.
//

#import "MKUIElementViewDetail.h"
#import "UIColor+MKUI.h"

@interface MKUIElementViewDetail()
@property(nonatomic,strong) UILabel *detailLabel;//详细
@end

@implementation MKUIElementViewDetail
- (id)initWithFrame:(CGRect)frame{
    if(self=[super initWithFrame:frame]){
        //
        self.detailLabel = [[UILabel alloc] init];
        self.detailLabel.font = [UIFont systemFontOfSize:16];
        self.detailLabel.textAlignment = NSTextAlignmentRight;
        self.detailLabel.numberOfLines = 1;
        self.detailLabel.textColor = [UIColor mk_colorWithLight:[UIColor mk_colorWithString:@"#838383"]];
        [self.contentView addSubview:self.detailLabel];
        //
        [self.segLayoutConstraint addItem:self.detailLabel];
    }
    return self;
}
- (void)setDetailText:(NSString *)detailText{
    if(_detailText==detailText || [_detailText isEqualToString:detailText]) return;
    _detailText = detailText;
    self.detailLabel.text = detailText;
    [self setNeedsLayout];
}
@end

@implementation MKUIElementListViewCellDetail
+ (Class)elementViewClass{
    return MKUIElementViewDetail.class;
}
@end

@implementation MKUIElementTableViewCellModelDetail
- (NSString *)el_detailText{
    return [self mk_stringForKeyPath:@"el_detailText"];
}
- (void)setEl_detailText:(NSString *)el_detailText{
    self[@"el_detailText"] = el_detailText;
    self.el_elementView.detailText = el_detailText;
}
@end
@implementation MKUIElementTableViewCellDetail
+ (Class)elementViewClass{
    return MKUIElementViewDetail.class;
}
- (void)customReloadCellModel{
    [super customReloadCellModel];
    MKUIElementTableViewCellModelDetail *cm = self.cellModel;
    MKUIElementViewDetail *elementView = self.elementView;
    elementView.detailText = cm.el_detailText;
}
@end
